
//选择配送员
function setCourier() {
    var courierId = $("input[name='chose_shopper']:checked").val();
    var orderNo = $('#order_no').val();

    if(checkIsNull(courierId)){
        alertTips("请选择配送员！");
        return false;
    }
    if(confirm("确定分配配送员？")){
        $.ajax({
            type: "post",
            url: '/mep/setCourier.do',
            dataType: "json",
            data: {
                'courier_id':courierId,
                'order_no':orderNo
            },
            success: function(resp){
                console.log(resp);
                if(resp.result==="success"){
                    location.reload();
                }else{
                    console.log("SetCourierError!");
                }
            }
        });
    }
}

//接单
function acceptOrder() {
    var order_no = $('#order_no').val();
    if(confirm("确定接收该订单？")){
        $.ajax({
            type: "post",
            url: '/mep/acceptOrder.do',
            dataType: "json",
            data: {
                'order_no':order_no,
                'message_id':$('#message_id').val()
            },
            success: function(resp){
                console.log(resp);
                if(resp.result==="success"){
                    location.reload();
                }else{
                    console.log("RejectOrderError!");
                }
            }
        });
    }
}


//拒单
function rejectOrder() {
    var reason = $('#reason').val();
    if(checkIsNull(reason)){
        alertTips("请填写原因！");
        return false;
    }
    var order_no = $('#order_no').val();
    var message_id = $('#message_id').val();
    if(confirm("确定要拒接该订单？")){
        $.ajax({
            type: "post",
            url: '/mep/rejectOrder.do',
            dataType: "json",
            data: {
                'reason':reason,
                'message_id':message_id,
                'order_no':order_no
            },
            success: function(resp){
                console.log(resp);
                if(resp.result==="success"){
                    location.href=ctx+'/mep/mepIndex.do'
                }else{
                    console.log("RejectOrderError!");
                }
            }
        });
    }

}